home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _D633BA01B11E45039811F7438C2B8FF6 < prev    next >
Encoding:
Text File  |  2004-01-06  |  2.1 KB  |  66 lines

  1. -- circular patroling behaviour - 
  2. --Each character will patrol a set of TagPoints in a circular way. ie 1 2 3 4 5 1 2 3 4 5 etc.
  3.  
  4. --The character will approach each TagPoint sequentialy, look in the direction of the current TagPoint, 
  5. --make some idles and look around. After the last TagPoint he will return to his first point and start again.
  6.  
  7. ---- OnBored will start a conversation if you have placed a AIANCHOR_RANDOM_TALK near where he is bored
  8.  
  9. -- created by sten:         18-09-2002
  10. -- last modified by sten:    17-10-2002
  11. -- last modified by petar
  12. ---------------------------------
  13.  
  14.  
  15. AIBehaviour.Job_FormPatrolCircle = {
  16.     Name = "Job_FormPatrolCircle",
  17.     JOB = 1,
  18.  
  19.     
  20.     -- SYSTEM EVENTS            -----
  21.     ---------------------------------------------
  22.     OnSpawn = function(self,entity )
  23.         entity:InitAIRelaxed();
  24.         entity.AI_PathStep = 0;
  25.         self:PatrolPath(entity);
  26.     end,
  27.     ---------------------------------------------        
  28.     OnJobContinue = function(self,entity )
  29.         entity:InitAIRelaxed();
  30.         self:PatrolPath(entity);
  31.     end,
  32.     ---------------------------------------------        
  33.     OnBored = function (self, entity)
  34.         entity:MakeRandomConversation();
  35.     end,
  36.     ----------------------------------------------------FUNCTIONS 
  37.     PatrolPath = function (self, entity, sender)
  38.         -- select next tagpoint for patrolling
  39.         local name = entity:GetName();
  40.  
  41.         local tpname = name.."_P0";    
  42.  
  43.         local TagPoint = Game:GetTagPoint(name.."_P"..entity.AI_PathStep);
  44.         if (TagPoint) then         
  45.             tpname = name.."_P"..entity.AI_PathStep;
  46.         else
  47.             if (entity.AI_PathStep == 0) then 
  48.                 System:Log("Warning: Entity "..name.." has a path job but no specified path points.");
  49.                 do return end
  50.             end
  51.             entity.AI_PathStep = 0;
  52.         end
  53.  
  54.         
  55.         entity:SelectPipe(0,"patrol_approach_to",tpname);
  56.         entity:InsertSubpipe(0,"make_formation");
  57.  
  58.         entity.AI_PathStep = entity.AI_PathStep + 1;
  59.     end,
  60.     
  61.     ------------------------------------------------------------------------
  62.     BREAK_AND_IDLE = function (self, entity, sender)
  63.     end,
  64.     ------------------------------------------------------------------------    
  65. }
  66.